/**
 * Created by no1 on 2015/7/30.
 */
"use strict";

var sequelize = require('../sequelize.js');
var Sequelize = require('sequelize');
let DataTypes = Sequelize;
var User = sequelize.define('mh_user', {
        uid: {
            type: DataTypes.INTEGER(10),
            primaryKey: true,
            autoIncrement: true,
            allowNull: false
        },
        groupid: {
            type: DataTypes.INTEGER(5),
            allowNull: false,
            defaultValue: '10'
        },
        nickname: {
            type: 'CHAR(10)',
            allowNull: true
        },
        nickname_ext: {
            type: DataTypes.INTEGER(2),
            allowNull: true,
            defaultValue: '0'
        },
        mobile: {
            type: DataTypes.BIGINT,
            allowNull: true
        },
        password: {
            type: 'CHAR(32)',
            allowNull: true,
            defaultValue: ''
        },
        salt: {
            type: 'CHAR(6)',
            allowNull: true,
            defaultValue: ''
        },
        email: {
            type: 'CHAR(35)',
            allowNull: true,
            defaultValue: ''
        },
        bodytype: {
            type: DataTypes.INTEGER(2),
            allowNull: true,
            defaultValue: '0'
        },
        regtime: {
            type: DataTypes.INTEGER(10),
            allowNull: true,
            defaultValue: '0'
        },
        regip: {
            type: 'CHAR(40)',
            allowNull: false
        },
        lastlogintime: {
            type: DataTypes.INTEGER(10),
            allowNull: true,
            defaultValue: '0'
        },
        lastloginip: {
            type: 'CHAR(40)',
            allowNull: false,
            defaultValue: ''
        },
        logintimes: {
            type: DataTypes.INTEGER(8),
            allowNull: false,
            defaultValue: '1'
        },
        bdate: {
            type: DataTypes.DATE,
            allowNull: true
        },
        credits: {
            type: DataTypes.INTEGER(10),
            allowNull: true,
            defaultValue: '0'
        },
        tokenkey: {
            type: 'CHAR(40)',
            allowNull: true
        },
        tokenttl: {
            type: DataTypes.INTEGER(10),
            allowNull: true,
            defaultValue: '0'
        },
        face: {
            type: DataTypes.INTEGER(3),
            allowNull: false,
            defaultValue: '1'
        },
        os_type: {
            type: DataTypes.INTEGER(1),
            allowNull: true,
            defaultValue: '0'
        },
        device_token: {
            type: 'CHAR(64)',
            allowNull: true,
            defaultValue: ''
        },
        mediatype: {
            type: DataTypes.INTEGER(2),
            allowNull: false,
            defaultValue: '0'
        },
        vip: {
            type: DataTypes.INTEGER(1),
            allowNull: false,
            defaultValue: '0'
        }
    },
    {
        indexes: [
            {
                unique: true,
                fields: ['name']
            }
        ],
        tableName: 'mh_user',
        createdAt: false,
        updatedAt: false
    }
);

module.exports = User;